package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.KDChangeAddress;

/**
 * 
 * @author 
 *
 */
@DAO
public interface KDChangeAddressDAO{
	
	@SQL("SELECT * FROM KDChangeAddress WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.link!=''){ and link like '%##(:t.link)%' } "
			+ "#if(:t.invoiceNo!=''){ and invoiceNo like '%##(:t.invoiceNo)%' } "
			+ "ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<KDChangeAddress> query(@SQLParam("t") KDChangeAddress kDChangeAddress);
	
	@SQL("SELECT count(*) FROM KDChangeAddress WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.link!=''){ and oldAddress like '%##(:t.link)%' } "
			+ "#if(:t.invoiceNo!=''){ and newAddress like '%##(:t.invoiceNo)%' } ")
    int querySzie(@SQLParam("t") KDChangeAddress kDChangeAddress);
    
    @SQL("select * from KDChangeAddress where id=:1")
    KDChangeAddress queryById(int id);
    
    @SQL("UPDATE KDChangeAddress SET memo=:2 WHERE id=:1")
    void updateMemoById(int id,String memo);
    
    @SQL("UPDATE KDChangeAddress SET status=1 WHERE id=:1")
    void updateStatusById(int id);
    
    @SQL("UPDATE KDChangeAddress SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    //导出数据
    @SQL("select id,type,link,phone,tel,invoiceNo,oldCity,oldArea,oldStreet,oldAddress,newCity,newArea,newStreet,newAddress,status,memo,deleteFlag,createAT,updateAT from KDChangeAddress where deleteFlag=1 #if(:start!=''){ and createAT>=:start } #if(:end!=''){ and createAT<=:end } order by id")
    List<Map> output(@SQLParam("start")String start, @SQLParam("end")String end);
}